class ListResult<T> {
  List<T>? lists;
  int page = 1;
  int count = 0;
  int total = 0;
  int totalPage = 0;

  ListResult.fromJson(Map<String, dynamic>? json, T Function(Map?) map) {
    if (json == null || !json.containsKey('lists')) {
      return;
    }

    lists = json['lists'].map<T>((item) => map(item as Map?)).toList();
    if (json.containsKey('page')) {
      page = json['page'];
    }
    if (json.containsKey('count')) {
      count = json['count'];
    }
    if (json.containsKey('total')) {
      total = json['total'];
    }
    if (json.containsKey('total_page')) {
      totalPage = json['total_page'];
    }
  }

  bool get hasList {
    return lists != null && lists!.isNotEmpty;
  }
}
